package com.ruoyi.recycle.domain;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

@Data
@Accessors(chain = true)
public class Coupon implements Serializable {
    private static final long serialVersionUID = -17288318510777815L;
    @ApiModelProperty(name = "id", value = "优惠券信息ID")
    @TableId(type = IdType.AUTO)
    private Long id;
    @ApiModelProperty(name = "couponName", value = "优惠券名称")
    private String couponName;
    @ApiModelProperty(name = "denomination", value = "优惠券面额")
    private BigDecimal denomination;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(name = "createTime", value = "创建时间,新增时不用传递")
    private Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "effectStart", value = "有效时间(开始)")
    private Date effectStart;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "effectEnd", value = "有效时间(结束)")
    private Date effectEnd;
    @ApiModelProperty(name = "type", value = "优惠券类型,满减券,代金券")
    private String type;
    @ApiModelProperty(name = "shopName", value = "引流平台名称")
    private String shopName;

    @ApiModelProperty(name = "condition", value = "使用条件说明")
    private String conditionDetail;

    @ApiModelProperty(name = "status", value = "优惠券状态,新增时不用传递")
    private String status;

    @ApiModelProperty(name = "shopId", value = "引流平台Id")
    private Long shopId;

    @ApiModelProperty(name = "number", value = "优惠券发行数量")
    private Integer number;

    public void setEffectEnd(Date effectEnd) {
        this.effectEnd = DateUtil.offsetSecond(effectEnd, 86399).toJdkDate();

    }


}
